package com.rainliang.project.connect.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.rainliang.project.util.DateUtil;


public class ConnectBean implements Serializable {
	/**
	 * 第三方账户的相关信息
	 */
	private static final long serialVersionUID = 1L;
	
	private Long userId;
	private String connectId;
	private String accessToken;
	private String refreshToken;
	private String tokenAttach;
	private Integer setting;
	private Integer isbind;
	private String createTime;
	private String updateTime;
	private Integer version;
	
	private Integer relation;
	
	public Long getUserId() {
		return userId;
	}
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	public String getConnectId() {
		return connectId;
	}
	public void setConnectId(String connectId) {
		this.connectId = connectId;
	}

	public String getAccessToken() {
		return accessToken;
	}
	public void setAccessToken(String accessToken) {
		this.accessToken = accessToken;
	}
	public String getRefreshToken() {
		return refreshToken;
	}
	public void setRefreshToken(String refreshToken) {
		this.refreshToken = refreshToken;
	}
	public String getTokenAttach() {
		return tokenAttach;
	}
	public void setTokenAttach(String tokenAttach) {
		this.tokenAttach = tokenAttach;
	}
	public Integer getSetting() {
		return setting;
	}
	public void setSetting(Integer setting) {
		this.setting = setting;
	}
	public Integer getIsbind() {
		return isbind;
	}
	public void setIsbind(Integer isbind) {
		this.isbind = isbind;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}
	public Integer getVersion() {
		return version;
	}
	public void setVersion(Integer version) {
		this.version = version;
	}
	
	public static ConnectBean parseMap(Map<String, Object> map) {
		ConnectBean rs = null;
		try {
			if (map != null && map.size() > 0) {
				rs = new ConnectBean();
				rs.setUserId((Long) map.get("user_id"));
				rs.setConnectId((String) map.get("conn_id"));
				rs.setSetting((Integer) map.get("conn_seting"));
				rs.setIsbind((Integer) map.get("conn_isbind"));
				rs.setAccessToken((String)map.get("access_token"));
				rs.setRefreshToken((String)map.get("refresh_token"));
				rs.setTokenAttach((String)map.get("token_attach"));
				rs.setCreateTime(DateUtil.getFormatDate((Date) map.get("create_time")));
				rs.setUpdateTime(DateUtil.getFormatDate((Date) map.get("update_time")));
				rs.setVersion((Integer)map.get("version"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return rs;
	}
	public ConnectBean(Long userId, String connectId, String accessToken,
			String refreshToken, String tokenAttach, Integer setting,Integer isbind) {
		super();
		this.userId = userId;
		this.connectId = connectId;
		this.accessToken = accessToken;
		this.refreshToken = refreshToken;
		this.tokenAttach = tokenAttach;
		this.setting = setting;
		this.isbind = isbind;
	}
	public ConnectBean() {
		super();
	}
	public static List<ConnectBean> parseMapList(List<Map<String, Object>> mapList) {
		if(mapList==null||mapList.size()<=0){
			return null;
		}
		List <ConnectBean> connList=new ArrayList<ConnectBean>();
		for(int i=0;i<mapList.size();i++){
			connList.add(parseMap(mapList.get(i)));
		}
		return connList;
	}
	public Integer getRelation() {
		return relation;
	}
	public void setRelation(Integer relation) {
		this.relation = relation;
	}
	 
}
